import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
//引入Element框架相关内容
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'



//引入图标相关
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
let app = createApp(App)
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
}


import './assets/icon/iconfont.css'
const debounce = (fn, delay) => {
    let timer = null;
    return function () {
        let context = this;
        let args = arguments;
        clearTimeout(timer);
        timer = setTimeout(function () {
            fn.apply(context, args);
        }, delay);
    }
}

import Antd from 'ant-design-vue';
// import 'ant-design-vue/dist/antd.css'


app.use(Antd).use(ElementPlus).use(store).use(router).mount('#app')

const BASE_URL = 'http://123.60.129.240'
//定义全局URL变量
window.BASE_URL = BASE_URL;
//在Vue实例中添加全局属性
app.config.globalProperties.BASE_URL = BASE_URL;

for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
}
//定义全局方法
window.getUser = ()=>{
    return localStorage.user?JSON.parse(localStorage.user):null;
}

const _ResizeObserver = window.ResizeObserver;
window.ResizeObserver = class ResizeObserver extends _ResizeObserver {
    constructor(callback) {
        callback = debounce(callback, 16);
        super(callback);
    }
}
